package com.gzw.dms.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gzw.dms.MyApplication;
import com.gzw.dms.R;
import com.gzw.dms.base.BaseActivity;
import com.gzw.dms.bean.UserInfo;
import com.gzw.dms.map.VehicleActivity;

public class MonitActivity extends BaseActivity {
    private TextView tv_ddfpnumber,tv_dpnumber;
    private Toolbar toolbar;
    private Context mContext;
    private LinearLayout layout_change,layout_cancle,layout_auditing;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void setContentView() {
        setContentView(R.layout.activity_monit);

    }

    @Override
    protected void initViews() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        tv_ddfpnumber = (TextView) findViewById(R.id.tv_ddfpnumber);
        tv_dpnumber = (TextView) findViewById(R.id.tv_dpnumber);
        layout_auditing = (LinearLayout) findViewById(R.id.layout_auditing);
        layout_cancle = (LinearLayout) findViewById(R.id.layout_cancle);

    }

    @Override
    protected void initData() {
        mContext = this;
        toolbar.setTitle("全图监控");
//        UserInfo userInfo = MyApplication.getUserInfo();
//        String flag = userInfo.getFlag();
//        if (flag.equals("1")||flag.equals("2")){
//            layout_auditing.setVisibility(View.GONE);
//            layout_change.setVisibility(View.GONE);
//        }else if (flag.equals("3")||flag.equals("4")){
//            layout_auditing.setVisibility(View.GONE);
//            layout_cancle.setVisibility(View.GONE);
//        }
    }

    @Override
    protected void initEvents() {
        toolbar.setNavigationOnClickListener(new MyOnClick());
        tv_ddfpnumber.setOnClickListener(new MyOnClick());
        tv_dpnumber.setOnClickListener(new MyOnClick());
    }

    class MyOnClick implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            Intent mIntent = new Intent();

            switch (v.getId()) {
                case R.id.tv_ddfpnumber:
                    mIntent.putExtra("fpstste", "0");
                    mIntent.setClass(mContext, VehicleActivity.class);
                    startActivityForResult(mIntent, 1);
                    break;
                case R.id.tv_dpnumber:
                    mIntent.putExtra("fpstste", "1");
                    mIntent.setClass(mContext, MonitMapActivity.class);
                    startActivityForResult(mIntent, 1);
                    break;

                default:
                    Intent mIntent1 = new Intent();
                    mIntent1.putExtra("result", 1);
                    //设置返回数据
                    setResult(3, mIntent1);
                    finish();
                    break;
            }
        }
    }
}
